left-square-bracketright-square-bracket
Type
operator
Summary
Returns a sequence array formed from the provided list of element values.
Syntax
[ <elementsList> ]
Description
Use the [ ] operator to create a sequence array from a list of expressions.
Each expression between [ and ] is evaluated and assigned to the next numeric index of the new sequence array, with the first index starting at one.
Evaluation of the element expressions proceeds from left to right, given an equivalence between a sequence array building expression and explicit sequence of put statements. For example:
get [ 1, cos(0.5), sin(0.5), 1 ]
Is equivalent to:
put 1 into it[1]
put cos(0.5) into it[2]
put sin(0.5) into it[3]
put 1 into it[4]
Element expressions can be any constant or non-constant expression, including sequence array and dictionary array expressions.
The list of element expressions may be followed by an optional comma which is ignored. Note:Due to allowing an optional trailing comma, element expressions in a sequence literal expression cannot be missing to indicate empty.
Parameters
Name | Type | Description |
---|---|---|
elementsList | A comma-separated list of zero or more expressions with optional trailing comma. |
Examples
[]
[ "a", 2 ]
[ 1, 1, 1 + 1, 2 + 1, 3 + 2, 5 + 3, ]
[ [], { "a": [ 1 ], "b": [ 2 ] }, [[]] ]
local tFirst, tSecond
put [ 1 ] into tFirst
put [ 2 ] into tSecond
get [ tFirst, tSecond ]
Related
glossay:
keyword: element
operator: left-bracerightbrace
Compatibility and Support
Introduced
LiveCode 10.0
OS
mac
windows
linux
ios
android
web
Platforms
desktop
server
mobile